package cn.newgrand.netcall.integration.setting;


import java.util.Properties;

import cn.newgrand.netcall.integration.AppSysRes;

/**
 * @author SidneyRen E-mail:SidneyRen@hotmail.com
 * @version create time：2010-12-31 下午02:08:28
 * 类说明
 */
public class SettingPreferences {
	
	private Properties props;
	
	private String loginURLIntranet;
	private String loginURLInternet;
	
	public SettingPreferences(){
		loginURLIntranet = AppSysRes.getPropertyOnServer(AppSysRes.APP_SERVER_LOGIN_URL_INTRANET);
		loginURLInternet = AppSysRes.getPropertyOnServer(AppSysRes.APP_SERVER_LOGIN_URL_INTERNET);
		this.props = new Properties();
	}
	
	public SettingPreferences(Properties props) {
		loginURLIntranet = AppSysRes.getPropertyOnServer(AppSysRes.APP_SERVER_LOGIN_URL_INTRANET);
		loginURLInternet = AppSysRes.getPropertyOnServer(AppSysRes.APP_SERVER_LOGIN_URL_INTERNET);
		this.props = props;
	}
	
	public Properties getProps() {
		return props;
	}

	public void setProps(Properties props) {
		this.props = props;
	}
	
	public String getAwayTime() {
		return props.getProperty("awayTime","60");
	}

	public void setAwayTime(String awayTime) {
		props.setProperty("awayTime", awayTime);
	}
	
	public String getOfflineTime() {
		return props.getProperty("offlineTime","180");
	}

	public void setOfflineTime(String offlineTime) {
		props.setProperty("offlineTime", offlineTime);
	}

	public String getLoginURLIntranet() {
		return props.getProperty("loginURLIntranet",loginURLIntranet);
	}

	public void setLoginURLIntranet(String loginURLIntranet) {
		props.setProperty("loginURLIntranet", loginURLIntranet);
	}

	public String getLoginURLInternet() {
		return props.getProperty("loginURLInternet",loginURLInternet);
	}

	public void setLoginURLInternet(String loginURLInternet) {
		props.setProperty("loginURLInternet", loginURLInternet);
	}

	public boolean isSelectedIntranet() {
		return Boolean.valueOf(props.getProperty("selectedIntranet","true"));
	}

	public void setSelectedIntranet(boolean selectedIntranet) {
		props.setProperty("selectedIntranet", Boolean.toString(selectedIntranet));
	}

	public boolean isSelectedInternet() {
		return Boolean.valueOf(props.getProperty("selectedInternet", "false"));
	}

	public void setSelectedInternet(boolean selectedInternet) {
		props.setProperty("selectedInternet", Boolean.toString(selectedInternet));
	}
	
	public String getSelectedLoginURL(){
		if(isSelectedInternet()){
			return loginURLInternet;
		}else{
			return loginURLIntranet;
		}
	}
}
